#include "ogre_logger.hpp"
#include "systems/logger.hpp"

void ogre_logger_impl_t::messageLogged(const Ogre::String &message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName)
{
    std::ostringstream msg;
    msg << "[" << logName << "] " << message;
    logger::detail::log_str(static_cast<log_level_t> (lml), msg.str());
}

ogre_logger_t::ogre_logger_t()
{
    //attach logger
    custom_log_mgr_ = new Ogre::LogManager();
    ogre_log_ = custom_log_mgr_->createLog("Ogre", true, false, true);
    ogre_logger_ = new ogre_logger_impl_t;
    ogre_log_->addListener(ogre_logger_);
}


ogre_logger_t::~ogre_logger_t()
{
    //detach logger
    ogre_log_->removeListener(ogre_logger_);
    delete ogre_logger_;
    custom_log_mgr_->destroyLog("Ogre");
    delete custom_log_mgr_;
}
